#ifndef B2D_TEXTURE_H
#define B2D_TEXTURE_H

#include "ITexture.h"

NS_B2D_BEGIN


////////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief	Common base class for all textures.
////////////////////////////////////////////////////////////////////////////////////////////////////
class B2D_API Texture
	: public ITexture
{
	B2D_OBJECT

protected:
	size_t		mWidth;
	size_t		mHeight;
	const int	mBorder;	// Needs to be 0 for ES2.0
	bool mHasMipmaps;


	//SamplerState mSamplerState;
	TextureFormat	mTextureFormat;

private:
	//bool mSamplerStateDirty;

public:
	Texture(void);
	virtual ~Texture(void);

	// :: IResource
	virtual void load(const StreamPtr& s);
	virtual size_t getSizeEstimate(void) const;

	// ::ITexture
	TextureFormat getFormat(void) const { return mTextureFormat; }
	size_t getWidth(void) const { return mWidth; }
	size_t getHeight(void) const { return mHeight; }
	int getBorder(void) const { return mBorder; }
	bool hasMipmaps(void) const { return mHasMipmaps; }
	bool hasAlpha(void) const;
	/*const SamplerState& getSamplerState(void) const { return mSamplerState; }
	void setSamplerState(const SamplerState& s) { mSamplerState = s; mSamplerStateDirty = true; }
	bool isSamplerStateDirty(void) const { return mSamplerStateDirty; }
	void updateSamplerState(void);*/
	void initialiseWithData(const void* data, size_t width, size_t height, TextureFormat format, bool mipmaps);

private:
	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// \brief	Sets pixel data implementation.
	/// 		This function assumes the pixels are set to an existant texture.
	///
	/// \param	data	The data.
	////////////////////////////////////////////////////////////////////////////////////////////////////
	virtual void initialiseWithDataImpl(const void* data) = 0;
	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// \brief	Updates the sampler state implementation.
	////////////////////////////////////////////////////////////////////////////////////////////////////
	//virtual void updateSamplerStateImpl(void) = 0;
};

NS_B2D_END

#endif